Quickstart: Parametric Frequency Sweep with the Python API
----------------------------------------------------------------

This tutorial uses :std:ref:`PFS test case in quickstart` provided with NeurEco installation.


To work with the Parametric Frequency Sweep NeurEco models in Python, import **NeurEcoFrequential** library: 

.. code-block:: python

    from NeurEco import NeurEcoFrequential as Frequential
	
Import numpy to handle the data sets:	

.. code-block:: python

    import numpy as np 

Load the data sets (see :std:ref:`Data preparation for NeurEco Parametric Frequency Sweep python` and :std:ref:`PFS test case in quickstart`):

.. code-block:: python

    x_train = np.load("inputs_train.npy")
    y_train = np.load("targets_train.npy")
    x_valid = np.load("inputs_valid.npy")
    y_valid = np.load("targets_valid.npy")
    x_test = np.load("inputs_test.npy")
    y_test = np.load("targets_test.npy")

To initialize a NeurEco object to handle the **Parametric Frequency Sweep** problem:

.. code-block:: python

    model = Frequential.PFS()

To build the model, call method **build** with the parameters set for the problem under consideration (see :std:ref:`Build NeurEco Parametric Frequency Sweep model with the Python API`). 
For this example, we provide a validation data set explicitly.

.. code-block:: python
    
     model.build(x_train, y_train,
                # the rest of these parameters are optional
                validation_input_data=x_valid,
                validation_output_data=y_valid,
                write_model_to="./FSS/model_fss.efnn",
                checkpoint_address="./FSS/fss.checkpoint")

.. note:: 
    For detailed documentation on **build**, see :std:ref:`Build NeurEco Parametric Frequency Sweep model with the Python API`.

To evaluate the NeurEco Model on the testing data (the second year of data), call **evaluate** method: 

.. code-block:: python

    neureco_outputs_test = model.evaluate(x_test)
	
.. note::
    For detailed documentation on **evaluate**, see :std:ref:`Evaluate NeurEco Parametric Frequency Sweep model with the Python API`.

To export the model as an FMU file:

.. code-block:: python

    model.export_fmu("./FSS/model_fss.fmu")

This export requires *neureco_embed_pfs* license.

.. note::
    For detailed documentation on **export**, see :std:ref:`Export NeurEco Parametric Frequency Sweep model python`

When the model is not needed any more, delete it from the memory:

.. code-block:: python

    model.delete()

.. note::
    For detailed documentation on Parametric Frequency Sweep with the python API, see :std:ref:`Parametric Frequency Sweep with the Python API`.